package com.factory.method_factory.order;

import com.factory.method_factory.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public abstract class OrderPizza {
    //抽象方法，让工厂的子类去决定如何 创建披萨
    public abstract Pizza createPizza(String pizzaType);

    //构造方法，用于开始创建Pizza对象
    public OrderPizza(){
        do {
            String pizzaType = getPizzaType();
            Pizza pizza = createPizza(pizzaType);
            //执行制作披萨的流程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    public String getPizzaType(){
        try {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("请输入披萨种类");
            String type= bf.readLine();
            return type;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }

    }
}
